<template>
	<view class="padding">
		<u-tabs :list="list" lineWidth="40" lineColor="#FA3121" :itemStyle="{width: '100%', height: '88rpx'}" :activeStyle="{color: '#6B0C00', 'font-weight': 'bold'}" :inactiveStyle="{color: '#6B0C00', 'font-weight': 'bold'}" :is-scroll="false" :current="current" @change="handelTab"></u-tabs>
		<view class="bg-white padding radius-8 margin-bottom margin-top-lg" v-for="(item, index) in rankRecordList" :key="index">
			<view class="flex justify-between">
				<view class="font-15 text-bold" style="width: 300rpx;">第{{item.day}}期<text v-if="item.ranking">丨排名{{item.ranking}}</text></view>
				<view class="font-15 text-bold word-break m-l-30">
					预消费{{(item.performance*(poolInfo && poolInfo.config && poolInfo.config[0].money) || 0).toFixed(2) || 0}}<text v-if="current == 0">/贡献值{{(item.performance*(poolInfo && poolInfo.config && poolInfo.config[1].money) || 0).toFixed(2) || 0}}</text>
				</view>
			</view>
			<view class="flex justify-between text-right">
				<view class="margin-top-sm font-13 text-gray">{{item.createTime}}</view>
				<view class="margin-top-sm font-13 text-theme" @click="toRank(item)">查看排名</view>
			</view>
		</view>
		<u-loadmore :status="status" />
	</view>
</template>

<script>
	import {
		poolBeforeList
	} from '@/common/api/customer.js'
	export default {
		data() {
			return {
				list: [
					{
						name: '服务商权益基金',
						type: ''
					}, 
					// {
					// 	name: '充值权益基金',
					// 	type: 1
					// }
				],
				rankRecordList: [],
				status: 'loading',
				pageNo: 0,
				current: 0,
				productArea: 3,
				poolInfo: {}
			};
		},
		onLoad() {
			this.getRankRecord()
		},
		onReachBottom() {
			this.getRankRecord()
		},
		methods: {
			resetData() {
				this.pageNo = 0
				this.rankRecordList = []
			},
			handelTab(e) {
				this.current = e.index
				this.resetData()
				if(this.current == 0) {
					this.productArea = 3
				}
				if(this.current == 1) {
					this.productArea = 6
				}
				this.getRankRecord()
			},
			getRankRecord() {
				this.pageNo++
				this.status = 'loading'
				poolBeforeList({pageNo: this.pageNo, pageSize: 10, productArea: this.productArea, releaseType: 1}).then(res=>{
					let dataList = []
					if(res.data && res.data.prizePool && res.data.prizePool.records) {
						dataList = res.data.prizePool.records || []
					}
					if(res.data) {
						this.poolInfo = res.data || {}
					}
					this.rankRecordList = this.rankRecordList.concat(dataList)
					if (dataList.length < 10) {
						this.status = 'nomore'
					}
				})
			},
			toRank(item) {
				let poolInfo = {
					yxf: this.poolInfo.config[0].money || 0,
					gxz: this.poolInfo.config[1].money || 0,
					day: item.day,
					performance: item.performance
				}
				uni.navigateTo({
					url: '/pages/my/dividendPool/rank?bunusId=' + item.id + '&current=' + this.current + '&poolInfo=' + JSON.stringify(poolInfo)
				})
			}
		}
	}
</script>

<style lang="scss">
page {
	background: #F2F3F5;
}
</style>
<style lang="scss" scoped>

</style>
